package model;

import base.BaseModel;
import base.BaseObserver;
import base.ResultCallBack;
import bean.ResultBean;
import bean.VideoBean;
import jiyun.com.yiyanmeng.http.HttpManager;
import jiyun.com.yiyanmeng.http.MySerivce;
import utils.RxUtil;

/**
 * Created by 裘翔 on 2019/11/6.
 */

public class ViewModel extends BaseModel {

    public void loadData(final ResultCallBack<VideoBean> callBack){
        MySerivce mySerivce = HttpManager.getInstance().getSerivce();
        mySerivce.getVideo()
                .compose(RxUtil.<ResultBean<VideoBean>>changeThread())
                .compose(RxUtil.<VideoBean>changeResult())
                .subscribe(new BaseObserver<VideoBean>() {
                    @Override
                    public void onSuccess(VideoBean videoBeans) {
                           callBack.onSuccess(videoBeans);
                    }

                    @Override
                    public void onFail(String error) {
                            callBack.onFail(error);
                    }
                });

    }
}
